<template>
  <div class="enterprises-signed">
    <van-nav-bar
      left-arrow
      class="title-bar"
      title="添加抄送方企业"
      :border="false"
      @click-left="$router.push('/ContractInformation')"
    />
    <van-field
      v-model="recipien.operatorContact"
      center
      label="经办人账号"
      placeholder="请输入手机/邮箱"
    >
      <van-icon
        slot="right-icon"
        class-prefix="iconfont iconmylianxiren"
        @click="$router.push('/frequent-contacts/' + 1)"
      ></van-icon>
    </van-field>
    <van-field
      v-model="recipien.operatorName"
      center
      label="经办人姓名"
      placeholder="请输入经办人真实姓名"
    />
    <van-field
      v-model="recipien.orgName"
      center
      label="企业名称"
      placeholder="请输入企业名称"
    />
    <div class="add-text-end">
      <van-button type="info" block @click="confirm">确定</van-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      recipien: {
        operatorContact: '',
        operatorName: '',
        orgName: ''
      }
    }
  },
  created() {
    this.recipien.operatorContact = this.$route.params.phone
    this.recipien.operatorName = this.$route.params.realName
    this.recipien.orgName = this.$route.params.orgName
  },
  mounted() {},
  methods: {
    // 获取参与人名称
    getSignerName(index) {
      if (index > 9) {
        return ''
      }
      var gan = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']
      return gan[index] + '方'
    },
    confirm() {
      if (
        this.recipien.operatorContact &&
        this.recipien.operatorName &&
        this.recipien.orgName
      ) {
        const org = {
          signerType: '1', // 签署方类型
          signerName: this.getSignerName(this.$store.state.recipien.length), // 签署方名称
          orgName: this.recipien.orgName, // 机构名称
          orgIdnumber: '', // 机构证件号
          userName: this.recipien.operatorName, // 经办人名称
          userIdnumber: '', // 经办人证件号
          userMobile: this.recipien.operatorContact, // 经办人手机号码
          sealTypeList: ['103'] // 签署印章
        }
        this.$store.commit('setRecipien', org)
        this.$router.push('ContractInformation')
      } else {
        this.$toast('必填项不能为空')
      }
    }
  }
}
</script>

<style scoped lang="less">
.enterprises-signed {
  height: 100vh;
  background-color: #f8f8f8;
  .title-bar {
    height: 128px;
    width: 100%;
    padding-top: 40px;
    box-sizing: border-box;
    margin-bottom: 20px;
    /deep/.van-nav-bar__title {
      font-size: 34px;
      font-weight: bold;
    }
    /deep/.van-icon {
      font-size: 48px;
      color: #000;
    }
  }
  .van-cell {
    height: 108px;
    /deep/.van-field__right-icon {
      color: #2489f2;
      .iconfont {
        font-size: 36px;
      }
    }
    /deep/.van-field__control {
      text-align: right;
    }
  }
  // 底部
  .add-text-end {
    height: 136px;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    margin-top: 32px;
    padding: 20px 40px;
    box-sizing: border-box;
    background-color: #fff;
  }
}
</style>
